luci-app-lxc: make regex for templates less strict
authorRichard Muzik <[email protected]>
Wed, 2 Jul 2025 05:40:43 +0000 (07:40 +0200)
committerPaul Donald <[email protected]>
Fri, 10 Oct 2025 15:08:49 +0000 (17:08 +0200)
Starting with LXC v6.0.0, the way templates are parsed has changed [1].
As a result, trailing whitespace is added to each string except the last
one. However, if the last string (i.e., a timestamp) is shorter—such as
when using a different timestamp format—trailing whitespace will still
be added.

This commit updates the regular expression to handle such cases.

[1] https://github.com/lxc/lxc/commit/84cc3155af502db586f644f1092831155e45ccca

Signed-off-by: Richard Muzik <[email protected]>
applications/luci-app-lxc/luasrc/controller/lxc.lua

index 5b603e52d91007b19beb42dc3dd218a5524e30dd..c1777a03d1adbb24bdebc14a34fca5d3cc3e816c 100644 (file)
@@ -61,7 +61,7 @@ function lxc_get_downloadable()
                %{ url }, 'r')
        local line
        for line in f:lines() do
-               local dist, version, dist_target = line:match("^(%S+)%s+(%S+)%s+(%S+)%s+default%s+%S+$")
+               local dist, version, dist_target = line:match("^(%S+)%s+(%S+)%s+(%S+)%s+default%s+(%S+)%s*$")
                if dist and version and dist_target and dist_target == target then
                        templates[#templates+1] = "%s:%s" %{ dist, version }
                end